import { requestOfGet, requestOfPost, requestOfPut, requestOfDelete } from './common'

export const $get = function (url:string, params: any = {}) {
  return new Promise((resolve, reject) => {
    requestOfGet(url, params)
      .then(res => resolve(res))
      .catch(errer => reject(errer))
  })
}

export const $post = function (url:string, params: any = {}) {
  return new Promise((resolve, reject) => {
    requestOfPost(url, params)
      .then(res => resolve(res))
      .catch(errer => reject(errer))
  })
}

export const $put = function (url:string, params: any = {}) {
  return new Promise((resolve, reject) => {
    requestOfPut(url, params)
      .then(res => resolve(res))
      .catch(errer => reject(errer))
  })
}

export const $delete = function (url:string, params: any = {}) {
  return new Promise((resolve, reject) => {
    requestOfDelete(url, params)
      .then(res => resolve(res))
      .catch(errer => reject(errer))
  })
}